package com.cskaoyan.javase.thread._2api;

/**
 * Java采取固定数值的静态优先级
 * 静态优先级固定数值的范围是1-10
 * （其中10表示最高优先级，1表示最低优先级，其余数值皆不合法）。
 *
 * getPriority()	int	返回该线程的优先级，数值必然在1-10之间
 * setPriority(int n)	void	设置线程的优先级，参数必然在1-10之间
 *
 * @since 11:29
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class PriorityDemo {
    public static void main(String[] args) {
        ThreadPriority t1 = new ThreadPriority("张三");
        ThreadPriority t2 = new ThreadPriority("李四");
        ThreadPriority t3 = new ThreadPriority("麻子");
        t1.setPriority(10);
        t2.setPriority(1);
        t1.start();
        t2.start();
        t3.start();
    }
}

class ThreadPriority extends Thread {
    public ThreadPriority(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(getName());
        }
    }
}
